package com.hainatong.mvvmbase.loadsir;

import android.os.Looper;
import com.hainatong.mvvmbase.loadsir.target.ITarget;

import java.util.List;

/**
 * 页面多状态 管理  https://github.com/KingJA/LoadSir
 * Create Time:2017/9/4 16:24
 * Author:KingJA
 * Email:kingjavip@gmail.com
 */
public class LoadSirUtil
{
    public static boolean isMainThread()
    {
        return Looper.myLooper() == Looper.getMainLooper();
    }

    public static ITarget getTargetContext(Object target, List<ITarget> targetContextList)
    {
        for (ITarget targetContext : targetContextList)
        {
            if (targetContext.equals(target))
            {
                return targetContext;
            }
        }
        throw new IllegalArgumentException("No TargetContext fit it");
    }
}
